<template>
  <!-- 排行榜（图） -->
  <div class="rank-container">
    <!-- 头部 -->
    <div class="rank-header">
      <span>排行榜</span>
      <span class="rank-header-more">
        更多
        <i class="el-icon-arrow-right"></i>
      </span>
    </div>
    <div  class="rank-item" v-for="(item,index) in ranklist" :key="index">
      <el-popover :disabled="isShow" :value="isShow"
          placement="top-start"
          width="320"
          trigger="hover"
          :visible-arrow="false"
          popper-class="rankpopper"
          :popper-options="{ boundariesElement: 'body', gpuAcceleration: false }">
          <div class="rank-content">
            <img :src="item.img" alt="">
            <div class="rank-content-info">
              <p class="rank-top-title">{{item.title}}</p>
              <p class="rank-top-time">
                <span>{{item.name}}</span>
                <span>·</span>
                <span>{{item.time}}</span>
              </p>
            </div>
          </div>
          <div class="rank-count">
            <ul>
              <li>
                <i class="iconfont icon-bofangliang"></i>
                {{item.playnum}}
              </li>
              <li>
                <i class="iconfont icon-pinglunshu"></i>
                {{item.comment}}
              </li>
              <li>
                <i class="iconfont icon-shoucang"></i>
                {{item.store}}
              </li>
              <li>
                <i class="iconfont icon-icon_shipin_yingbishu"></i>
                {{item.coin}}
              </li>
            </ul>
          </div>
      <div slot="reference" class="rank-item-content" @mouseenter="rankEnter(type,index)" @mouseleave="rankLeave(type,index)">
        <!-- <div slot="reference" class="rank-item-content"> -->
        <span class="rank-item-order" :class="index<=2? 'orderActive' : ''">{{index+1}}</span>
        <div class="rank-item-box" v-if="item.intro">
          <div class="rank-item-pic">
            <img :src="item.img" alt="">
            <div class="rank-item-laterbox" v-if="type == false">
              <i class="iconfont icon-shaohouzaikanx1"></i>
              <span class="rank-item-latertext">稍后再看</span>
            </div>
          </div>
          <div class="rank-item-info">
            <p class="rank-item-info-title" :title="item.title">{{item.title}}</p>
            <span>综合得分:{{item.intro}}</span>
          </div>
        </div>
        <p class="rank-item-title" v-if=" index!= 0 " :title="item.title">{{item.title}}</p>
      </div>
      </el-popover>
    </div>
  </div>
</template>

<script>
  export default{
    name:'RankList',
    props:{
      ranklist:Array,
      type:{
        type:Boolean,
        required:false,
        default:false
      }
    },
    data(){
      return{
        isShow:false,
      }
    },
    methods:{
      rankEnter(type,index){
        if(type == true){
          this.isShow = true
        }else{
          this.isShow = false
        }
      },
      rankLeave(type,index){
        if(this.type == true){
          this.isShow = true
        }else{
          this.isShow = true
        }
      }
    }
  }
</script>

<style scoped>
  .rank-container{
    width:320px;
  }
  .rank-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    height: 36px;
  }
  .rank-header>span:nth-child(1){
    display: inline-block;
    color:#212121;
    vertical-align: bottom;
    font-size: 20px;
    line-height: 28px;
  }
  .rank-header-more{
    display: flex;
    align-items: center;
    padding:0 0 0 12px;
    width: 58px;
    box-sizing: border-box;
    height: 22px;
    border: 1px solid silver;
    border-radius: 2px;
    color:#505050;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    transition: background-color .2s;
    cursor: pointer;
  }
  .rank-header-more>i{
    vertical-align: middle;
    font-size: 14px;
  }
  .rank-header-more:hover{
    background-color: #f4f4f4;
  }
  .rank-item{

    margin-bottom: 18px;
  }
  .rank-item-content{
    position: relative;
    display: flex;
    justify-content: space-between;
  }

  .rank-item-order{
    font-size: 14px;
    color:#999;
    width: 18px;
    height: 18px;
    text-align: center;
    line-height: 18px;
    border-radius: 2px;
    display: inline-block;
  }
  .orderActive{
    background: #00A1D6;
    color:#fff;
  }
  .rank-item-box{
    /* position: relative; */
    width: 290px;
    display: flex;
    font-weight: 500;
  }
  .rank-item-pic{
    position: relative;
    cursor: pointer;
  }
  .rank-item-pic>img{
    width: 112px;
    height: 63px;
    border-radius: 2px;
  }
  .rank-item-laterbox{
    position: absolute;
    width:28px;
    height:28px;
    z-index: 20;
    right: 8px;
    bottom:8px;
    cursor: pointer;
    background: rgba(0,0,0,.6);
    border-radius: 2px;
    line-height: 28px;
    opacity: 0;
    transition: all .2s .2s;
  }
  .rank-item-laterbox>i{
    font-size: 28px;
    color:#fff;
  }
  .rank-item-pic:hover .rank-item-laterbox{
    opacity: 1;
  }
  .rank-item-latertext{
    position: absolute;
    padding: 4px 8px;
    left: -19px;
    top:-28px;
    background: rgba(0,0,0,.7);
    color:#fff;
    white-space: nowrap;
    line-height: 18px;
    border-radius: 4px;
    transform: scale(0);
    transition: all .2s;
  }
  .rank-item-laterbox:hover .rank-item-latertext{
    transform: scale(1);
  }
  .rank-item-info{
    margin-left:12px;
  }
  .rank-item-info-title{
    font-size: 14px;
    height: 40px;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 5px;
    color:#212121;
    cursor: pointer;
    transition: color .3s;
  }
  .rank-item-info-title:hover{
    color:#00A1D6;
  }
  .rank-item-info>span{
    color: #999;
    white-space: nowrap;
  }
  .rank-item-title{
    width:290px;
    font-size: 14px;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: color .3s;
  }
  .rank-item-title:hover{
    color:#00A1D6;
  }
  .rank-content{
    display: flex;
  }
  .rank-content>img{
    width: 112px;
    height:63px;
    border-radius: 2px;
  }
  .rank-content-info{
    padding-left: 10px;
  }
  .rank-top-title{
    word-break: break-all;/*允许在单词内换行。*/
    max-height: 40px;
    color:#212121;
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .rank-top-time{
    display: flex;
    color:#999;
    font-size: 12px;
    line-height: 16px;
  }
  .rank-count{
    border-top: 1px solid #e7e7e7;
    padding-top: 12px;
    margin-top: 12px;
  }
  .rank-count>ul{
    display: flex;
    justify-content: space-between;
  }
  .rank-count>ul>li{
    font-size: 12px;
    color:#999;
    display: flex;
    align-items: center;
  }
  .rank-count>ul>li>i{
    margin-right: 3px;
    /* vertical-align: middle; */
    font-size: 18px;
  }

</style>
<style>
  .rankpopper{
    width: 320px;
    box-sizing: border-box;
  }
</style>
